package com.study.demo.valid;

import org.junit.Test;

import java.lang.reflect.Field;

/**
 * @author liuhongzhen
 * @date 2022/4/26 13:07
 */
public class DoubleToIntDemo {


    @Test
    public void testMyField() {
        // 获取类模板
        Class c = DoubleToIntDto.class;
        // 获取所有字段
        for (Field f : c.getDeclaredFields()) {
            // 判断这个字段是否有MyField注解
            if (f.isAnnotationPresent(DoubleToInt.class)) {
                DoubleToInt annotation = f.getAnnotation(DoubleToInt.class);
                System.out.println("字段:[" + f.getName() + "], 描述:[" + annotation.description()+"]");
            }
        }
    }
}
